package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.taotao.common.pojo.PictureResult;
import com.taotao.common.util.JsonUtils;
import com.taotao.service.PictureService;

/****
 * 图片管理controller
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/pic")
public class PictureController {
	
	//图片管理service
	@Autowired
	private PictureService pictureService;
	
	@RequestMapping("/upload")
	@ResponseBody
	public String uploda(MultipartFile uploadFile) throws Exception {
		//调用service上传图片
		PictureResult pictureResult = pictureService.uploadFile(uploadFile);
		//为了保证兼容性,需要把result转成json格式字符串
		String json = JsonUtils.objectToJson(pictureResult);
		//返回上传结果
		return json;
	}
	
}
